﻿using System;
using System.Collections.Generic;
using System.Text;

namespace RaisingStudio.Data.Expressions
{
    [Serializable]
    public class ColumnExpressionCollection : List<ColumnExpression>
    {
        public ColumnExpressionCollection(ColumnExpression[] columns)
            : base(columns)
        {
        }

        public ColumnExpressionCollection Except(params RaisingStudio.Data.Expressions.ColumnExpression[] columns)
        {
            ColumnExpressionCollection columnExpressionCollection = new ColumnExpressionCollection(this);
            if ((columns != null) && (columns.Length > 0))
            {
                foreach (RaisingStudio.Data.Expressions.ColumnExpression column in columns)
                {
                    columnExpressionCollection.Remove(column);
                }
            }
            return columnExpressionCollection;
        }
        
        #region type 转换
        public static implicit operator ColumnExpressionCollection(ColumnExpression[] columns)
        {
            return new ColumnExpressionCollection(columns);
        }

        public static implicit operator ColumnExpression[](ColumnExpressionCollection columnExpressionCollection)
        {
            if (columnExpressionCollection != null)
            {
                return columnExpressionCollection.ToArray();
            }
            return null;
        }
        #endregion
    }
}
